import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:rembercount/bings/appBings.dart';
import 'package:rembercount/controller/countController.dart';
import 'package:rembercount/controller/themeController.dart';
import 'package:rembercount/pages/loginscreen.dart';
import 'package:rembercount/pages/homepage.dart';
import 'package:rembercount/pages/main_page.dart';
import 'package:rembercount/pages/myAccount.dart';
import 'package:rembercount/pages/tab.dart';
import 'package:rembercount/pages/register.dart';
import 'package:rembercount/router/appMiddleware.dart';
import 'package:rembercount/pages/forgetPassword.dart';
import 'package:rembercount/pages/record_page.dart';
import 'package:rembercount/components/transaction_details_card.dart';
// import 'package:rembercount/pages/login_page.dart';
import 'package:rembercount/pages/settings_page.dart';
import 'package:rembercount/pages/profile_page.dart';
// import 'package:rembercount/middleware/appmiddleware.dart';
import 'package:rembercount/pages/edit_profile_page.dart';

class AppRouter {
  static const String login = '/login';
  static const String register = '/register';
  static const String transaction_details_card = '/transaction_details_card';
  static const String home = '/home';
  static const String tabpage = '/tabpage';
  static const String record = '/record';
  static const String account = '/account';
  static const String settings = '/settings';
  static const String forgetPassword = '/forgetPassword';
  static const String mainpage = '/mainpage';
  static const String editprofile = '/edit-profile';
  static const String myaccount = '/myaccount';


  static final List<GetPage> routes = [
    GetPage(name: login, page: () => LoginScreen()),
    GetPage(
      name: record,
      page: () => const RecordPage(),
    ),
    GetPage(
      name: '/transaction-details',
      page: () => Material(
        child: TransactionDetailsCard(
          countController: Get.find<CountController>(),
          record: Get.arguments['record'] ?? {},
          themeController: Get.find<ThemeController>(),
          onUpdate: (record) {
            // 返回上一页并刷新数据
            Get.back(result: true);
          },
        ),
      ),
    ),
    GetPage(name: register, page: () => RegisterScreen()),
    GetPage(name: editprofile, page: () => EditProfilePage()),
    GetPage(name: forgetPassword, page: () => ForgotPasswordScreen()),
    GetPage(name: home, page: () => Homepage(), middlewares: [Appmiddleware()]),
    GetPage(
      name: tabpage,
      page: () => TabPage(),
      middlewares: [Appmiddleware()],
    ),
    GetPage(
      name: mainpage,
      page: () => MainPage(),
      middlewares: [Appmiddleware()],
    ),
    // GetPage(name: record, page: () => RecordScreen()),
    // GetPage(name: account, page: () => AccountScreen()),
    GetPage(
      name: settings,
      page: () => const SettingsPage(),
    ),
    GetPage(
      name: '/profile',
      page: () => ProfilePage(),
    ),
    GetPage(
      name: '/myaccount',
      page: () => Myaccount(),
    ),
  ];
}
